package com.company.behavioral.visitor_pattern.concrete_visitor;

import com.company.behavioral.visitor_pattern.concrete_element.FulltimeEmployee;
import com.company.behavioral.visitor_pattern.concrete_element.ParttimeEmployee;
import com.company.behavioral.visitor_pattern.visitor.Department;

/**
 * 财务部门
 * @ClassName FADepartment
 * @Author tiezheng.han
 * @Date 2020/9/7 16:42
 **/
public class FADepartment extends Department {


    /**
     * 实现财务部门对全职员工的访问
     * @param employee
     */
    @Override
    public void visit(FulltimeEmployee employee) {
        int workTime = employee.getWorkTime();
        double weekWage = employee.getWeeklyWage();
        if (workTime > 40) {
            weekWage = weekWage + (workTime - 40) * 100;
        } else if (workTime < 40) {
            weekWage = weekWage - (40 - workTime) * 80;
            if (workTime < 0) {
                weekWage = 0;
            }
        }
        System.out.println("正式员工" + employee.getName() + "实际工资为：" + weekWage + "元。");
    }

    /**
     * 实现财务部对兼职员工的访问
     * @param employee
     */
    @Override
    public void visit(ParttimeEmployee employee) {
        int workTime = employee.getWorkTime();
        double hourWage = employee.getHourWage();
        System.out.println("临时员工" + employee.getName() + "实际工资为：" + workTime * hourWage + "元。");
    }
}
